<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>xiaoniu-registry 服务注册中心</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        .status-healthy { color: #28a745; }
        .status-unhealthy { color: #dc3545; }
        .status-offline { color: #6c757d; }
        .metric-card { transition: transform 0.2s; }
        .metric-card:hover { transform: translateY(-2px); }
        .refresh-btn { transition: transform 0.2s; }
        .refresh-btn:hover { transform: rotate(180deg); }
    </style>
</head>
<body class="bg-light">
<nav class="navbar navbar-dark bg-primary">
    <div class="container">
        <span class="navbar-brand mb-0 h1">
            <i class="bi bi-hdd-network"></i> xiaoniu-registry 服务注册中心
        </span>
        <div class="d-flex">
            <button class="btn btn-outline-light me-2" onclick="showMetrics()">
                <i class="bi bi-graph-up"></i> 监控
            </button>
            <button class="btn btn-outline-light refresh-btn" onclick="refreshAll()">
                <i class="bi bi-arrow-clockwise"></i> 刷新
            </button>
        </div>
    </div>
</nav>

<div class="container mt-4">
    <!-- 系统概览 -->
    <div class="row mb-4">
        <div class="col-md-3">
            <div class="card metric-card">
                <div class="card-body text-center">
                    <i class="bi bi-server fs-1 text-primary"></i>
                    <h5 class="card-title mt-2">服务总数</h5>
                    <h3 class="text-primary" id="totalServices">-</h3>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card metric-card">
                <div class="card-body text-center">
                    <i class="bi bi-diagram-3 fs-1 text-info"></i>
                    <h5 class="card-title mt-2">实例总数</h5>
                    <h3 class="text-info" id="totalInstances">-</h3>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card metric-card">
                <div class="card-body text-center">
                    <i class="bi bi-heart-pulse fs-1 text-success"></i>
                    <h5 class="card-title mt-2">健康实例</h5>
                    <h3 class="text-success" id="healthyInstances">-</h3>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card metric-card">
                <div class="card-body text-center">
                    <i class="bi bi-clock fs-1 text-warning"></i>
                    <h5 class="card-title mt-2">运行时间</h5>
                    <h6 class="text-warning" id="uptime">-</h6>
                </div>
            </div>
        </div>
    </div>

    <!-- 服务列表 -->
    <div class="card">
        <div class="card-header">
            <h5 class="mb-0">
                <i class="bi bi-list-ul"></i> 服务列表
                <span class="badge bg-secondary ms-2" id="serviceCount">0</span>
            </h5>
        </div>
        <div class="card-body">
             <div id="serviceList">
                 <div class="text-center py-4">
                     <div class="spinner-border text-primary" role="status">
                         <span class="visually-hidden">加载中...</span>
                     </div>
                     <p class="mt-2 text-muted">正在加载服务列表...</p>
                 </div>
             </div>
         </div>
    </div>
</div>

<!-- 监控模态框 -->
<div class="modal fade" id="metricsModal" tabindex="-1">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">
                    <i class="bi bi-graph-up"></i> 系统监控
                </h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body">
                <div id="metricsContent">
                    <div class="text-center py-4">
                        <div class="spinner-border text-primary" role="status">
                            <span class="visually-hidden">加载中...</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
 <script src="/frontend/template/js/index.js"></script>
</body>
</html>